An image processing apparatus has been known which acquires image data by reading a document and detects a document region from the image data. For example, the image processing apparatus acquires an image containing a document region, detects coordinate values of edge candidate pixels based on the obtained image, calculates the tilting of the document region based on the detected coordinate values of the edge candidate pixels, and extracts coordinate values of edge end candidate pixels based on the detected coordinate values of the edge candidate pixels. Then, the image processing apparatus calculates a straight line corresponding to an edge based on the calculated tilting of the document region and the extracted coordinate values of edge end candidate pixels, and corrects the tilting of the document region on the basis of the calculated straight line corresponding to the edge, and crops the document region from the image based on the relevant straight line.
Also, an image processing method has been known which is capable of detecting an angle of a line depicted by image data. In this image processing method, edge intensity of a focused pixel is calculated, the edge intensity is compared with a threshold value, an edge direction is calculated, edge direction histogram is produced, peak angle is determined based on the produced edge direction histogram, a polar coordinate histogram is produced by Hough transformation based on edge pixel within a range around the peak angle, a provisional line is determined based on the polar coordinate histogram, a longest line segment of the provisional line is detected, and an angle of the line is determined from regression line based on the least square method.
Related art is disclosed in Japanese Laid-open Patent Publications No. 2009-218953 and 2005-322044.